package com.ruoqing.admin.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
	* @author YaoXian
	* @title: SwaggerConfig
	* @projectName ruoxi-blog
	* @description: 若兮微服务 - 后台管理中心 - 配置swaggerApi文档的描述
	* @date 2020-11-15 15:50
	*/
@EnableSwagger2
@Configuration
public class SwaggerConfig {
		
		/**
			* 创建API
			*/
		@Bean
		public Docket createRestApi() {
				return new Docket(DocumentationType.SWAGGER_2)
								// 详细定制
								.apiInfo(apiInfo("1.0.0"))
								.select()
								// 指定扫描的包路径
								.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
								// 扫描所有
								.paths(PathSelectors.any())
								.build();
		}
		
		/**
			* 添加摘要信息
			*/
		private ApiInfo apiInfo(String version) {
				// 用ApiInfoBuilder进行定制
				return new ApiInfoBuilder()
								.title("若兮微服务 - 后台管理中心 - Api接口文档")
								.version(version)
								.build();
		}
}